'from The Visual Basic 5.0 API declarations document
'Win32API.txt
Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
Public Const SRCCOPY = &HCC0020 ' (DWORD) dest = source
Public Const SRCPAINT = &HEE0086 ' (DWORD) dest = source OR dest
Public Const SRCAND = &H8800C6 ' (DWORD) dest = source AND dest
Public Const SRCINVERT = &H660046 ' (DWORD) dest = source XOR dest
Public Const SRCERASE = &H440328 ' (DWORD) dest = source AND (NOT dest )
Public Const NOTSRCCOPY = &H330008 ' (DWORD) dest = (NOT source)
Public Const NOTSRCERASE = &H1100A6 ' (DWORD) dest = (NOT src) AND (NOT dest)
Public Type ONE_PIECE
Width As Long
Height As Long
OnBmp_x As Long 'x pos of the piece on the Pieces.BMP file
OnBmp_y As Long 'y pos
MaskOnBmp_x As Long 'x pos of the mask on the Pieces.BMP file
MaskOnBmp_y As Long 'y pos
Creating_x As Long 'Center the piece on release
Creating_Piece_No As Long 'Allways release the good one.
Next_Piece_Pos_x As Long 'Center the piece on the next piece window
Next_Piece_Pos_y As Long 'Same
After_Turn_Piece_No As Long 'Which one will be the next piece after turn
After_Turn_dx As Long 'if it will turn, how much will
After_Turn_dy As Long 'be the x,y differences on turn
Number_Of_Positions_To_Check_Left As Long 'Number of positions To check on the left, right and down
Number_Of_Positions_To_Check_Right As Long
Number_Of_Positions_To_Check_Down As Long
Check_These_Positions_Left_x(9) As Long 'X and Y coordinates of the Positions to check if empty or not
Check_These_Positions_Left_y(9) As Long
Check_These_Positions_Right_x(9) As Long
Check_These_Positions_Right_y(9) As Long
Check_These_Positions_Down_x(9) As Long
Check_These_Positions_Down_y(9) As Long
Number_Of_Squares As Long 'It is allways equal to 4
Piece_Is_This_x(4) As Long
Piece_Is_This_y(4) As Long
End Type
Type PIECE_PERMISSIONS
Left(1 To 18, 0 To 11) As Boolean
Right(1 To 18, 0 To 11) As Boolean
Vertical(1 To 18, 0 To 11) As Boolean
Left2(1 To 18, 0 To 11) As Boolean
Right2(1 To 18, 0 To 11) As Boolean
Vertical2(1 To 18, 0 To 11) As Boolean
End Type
Public Piece(19) As ONE_PIECE
Public Piece_No_Permission As PIECE_PERMISSIONS
Public Score As Long
Public Vertical_Stop_Time As Single
Public Vx As Single
Public Vy As Single
Public Vy_Level As Single
Public Level As Long
Public x As Single
Public y As Single
Public Prv_x As Single
Public Prv_y As Single
Public Piece_No As Long
Public Prv_Piece_No As Long
Public Next_Piece_No As Long
Public Position_Empty(1 To 18, 0 To 11) As Boolean
Public Copied_To_BMP As Boolean
Public Game_Is_Started As Boolean
Public Game_Is_About_To_End As Boolean
Public Key_Up As Boolean
Public Vertical_Stop_Status As Boolean
Public Left_Stop_Status As Boolean
Public Right_Stop_Status As Boolean
Public Prv_Vertical_Stop_Status As Boolean
Public Prv_Left_Stop_Status As Boolean
Public Prv_Right_Stop_Status As Boolean
Public Right_Move_Requested As Boolean
Public Left_Move_Requested As Boolean
Public Piece_Stopped As Boolean
Sub Draw_The_Piece(DTP_Prv_Piece_No As Long, DTP_Piece_No As Long, DTP_x As Long, DTP_y As Long, DTP_Px As Long, DTP_Py As Long)
'First, copy the previous background back
'Then copy the new position content to a blank area on picture box BMP
'Draw the mask
'and draw the piece to its new position.
If Copied_To_BMP = True Then BitBlt Form1.Picture1.hDC, DTP_Px, DTP_Py, Piece(DTP_Prv_Piece_No).Width, Piece(DTP_Prv_Piece_No).Height, Form1.BMP.hDC, 408, 240, SRCCOPY